﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// Reviewed

#pragma once

#include "GcmpDatabaseInterface.h"
#include "GbmpQuickCast.h"
#include "OwnerPtr.h"
#include "IObject.h"
#include <vector>

namespace gcmp
{
    class IDbObject;

    /// \brief 反序列化行为接口
    class GCMP_DATABASE_INTERFACE_EXPORT IUnserializationBehavior : public IObject
    {
        DEFINE_CAST_DERIVED(IUnserializationBehavior, IObject);
    public:
        /// \brief 从数据中创建对象实例
        ///
        /// \param bytes 反序列化对象需要的数据
        /// \param[out] OwnerPtr<IDbObject> 创建出的对象
        /// \return bool 是否创建成功
        virtual bool ConstructObject(
            const std::vector<char> & bytes,
            OwnerPtr<IDbObject> & opIDbObject
        ) = 0;

    public:
        /// \brief 析构函数
        virtual ~IUnserializationBehavior(void) = 0;
    };
}

